class CreateRouters < ActiveRecord::Migration
  def self.up
    #固定交路表
    create_table :routers do |t|
      t.string              :train_number                      #车次组合
      t.string              :line                              #行车路线
      t.integer             :length                            #一次行走公里数

      t.integer   :is_locked     ,:limit => 1 ,:default => 0      #锁定 1为True 0为False
      t.integer   :lock_version  ,:default => 0                   #乐观锁
      t.timestamps
    end

    Router.create(:train_number => "停留",:line => "停留",:length => 0)
    Router.create(:train_number => "临行交路",:line => "临行交路",:length => 0)
    Router.create(:train_number => "D76、D77",:line => "上海-青岛-上海",:length => 1350)
    Router.create(:train_number => "D75、D78",:line => "青岛-上海-青岛",:length => 1350)
    Router.create(:train_number => "D6064/1、D34、D33、D6062/3",:line => "青岛-泰山-北京南-泰山-青岛",:length => 1979)
    Router.create(:train_number => "55096/7/D60、D57",:line => "青岛-北京南-青岛",:length => 1840)
    Router.create(:train_number => "D6003、D6008、D6013、D6020、D6023",:line => "济南-青岛-济南-青岛-济南-青岛",:length => 1850)
    Router.create(:train_number => "D6005、D6012、D6017",:line => "济南-青岛-济南-青岛",:length => 1110)
    Router.create(:train_number => "D58、D37、D38",:line => "青岛-北京南-济南-北京南",:length => 1775)
    Router.create(:train_number => "D35、D36、D59",:line => "北京南-济南-北京南-青岛",:length => 1775)
    Router.create(:train_number => "D62、D61",:line => "青岛-北京南-青岛",:length => 1660)
    Router.create(:train_number => "D6072、D40、D39、D6071",:line => "青岛-济南-北京南-济南-青岛",:length => 1670)
    Router.create(:train_number => "D6004、D6009、D6016",:line => "青岛-济南-青岛-济南",:length => 1850)
    Router.create(:train_number => "D6002、D6007、D6014、D6019、D6024",:line => "青岛-济南-青岛-济南-青岛-济南",:length => 1850)
    Router.create(:train_number => "D6010、D6015、D6022",:line => "青岛-济南-青岛-济南",:length => 1110)
    Router.create(:train_number => "55504、55503",:line => "港湾-济南东-港湾",:length => 3923)
    Router.create(:train_number => "D6001、D6006、D6011、D6018、D6021",:line => "济南-青岛-济南-青岛-济南-青岛",:length => 1850)
  end

  def self.down
    drop_table :routers
  end
end
